<template>
  <div>
    <el-dialog title="审核售后" :visible.sync="visible" :before-close="closeDialog" :width="dialogWidth">
      <div>
        <el-radio-group v-model="statusrideo">
          <el-radio :label="1">通过</el-radio>
          <el-radio :label="2">未通过</el-radio>
        </el-radio-group>
        <transition name="el-fade-in-linear">
          <div v-if="statusrideo === 2" style="margin-top: 10px;border: 1px solid #F1F1F1;padding: 10px;">
            <div style="margin-bottom: 10px;">理由</div>
            <el-checkbox-group v-model="reasontype" :max="1" class="el-checkbox-block">
              <el-checkbox :label="1">不符合销售范围</el-checkbox>
              <el-checkbox :label="2">退换货商品影响二次销售</el-checkbox>
              <el-checkbox :label="3">其他</el-checkbox>
            </el-checkbox-group>
            <div style="margin-top: 10px">
              <el-input
                v-if="reasontype && reasontype[0]===3"
                v-model="reason"
                type="text"
                placeholder="请输入内容"
                maxlength="200"
                show-word-limit
              />
            </div>
          </div>
        </transition>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { aftermarketExamine } from '@/api/aftermarket'
import dialogMixin from '@/components/Mixins/dialog'
export default {
  mixins: [dialogMixin],
  // props: ['visible', 'aftermarketid'],
  props: {
    visible: { type: Boolean, default: false },
    aftermarketid: { type: String, default: null }
  },
  data() {
    return {
      statusrideo: 1,
      reasontype: [],
      reason: null
    }
  },
  methods: {
    async submitForm() {
      const res = await aftermarketExamine({
        aftermarketid: this.aftermarketid, // 售后订单号
        status: this.statusrideo, // 售后状态
        reasontype: this.reasontype[0] ? this.reasontype[0] : '',
        reason: this.reasontype[0] === 3 ? this.reason : ''
      })
      this.closeDialog()
      this.$notify({
        title: '提示',
        type: res.code === 1001 ? 'success' : 'error',
        message: res.msg,
        position: 'bottom-right'
      })
    },
    resetFile() {
      this.statusrideo = 1
      this.reasontype = []
      this.reason = null
    },
    closeDialog() {
      this.resetFile()
      this.$emit('update:visible', false)
      this.$emit('getData')
    }
  }
}
</script>
